<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="demo-form-inline">
      <el-form-item label="ID" prop="userId">
        <el-input v-model="queryParams.userId" placeholder="id" />
      </el-form-item>
      <el-form-item label="日期" prop="date">
        <el-date-picker
          v-model="queryParams.date"
          type="datetime"
          placeholder="选择日期"
          value-format="yyyy-MM-dd"
        />
      </el-form-item>

      <el-form-item label="排序" prop="orderBy">
        <el-select v-model="queryParams.orderBy" placeholder="请选择">
          <el-option v-for="(item,index) in statusOptions" :key="index" :label="item.label" :value="item.id" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="发放金额总和">
        {{ message }}
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item>

      
    </el-form>
    <div v-if="statistics.ddTeamGameWater&&queryParams.date">
      <p style="white-space: pre-wrap">当日业绩:{{ statistics.ddTeamGameWater }}</p>
      <p style="white-space: pre-wrap">当日团队奖:{{ statistics.ddTeamGameWaterAmount }}</p>
      <p style="white-space: pre-wrap">当日下级团队奖:{{ statistics.childrenDdTeamGameWaterAmount }}</p>

    </div>

    <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row>
      <!-- <el-table-column align="center" label="序号" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column> -->
      <el-table-column label="用户ID" align="center" prop="userId" />
      <el-table-column label="昵称" align="center" prop="nickName" />
      <el-table-column label="备注	" align="center" prop="remarks" />

      <el-table-column label="日期" align="center" prop="today" />
      <!-- <el-table-column label="当日流水" align="center" prop="todayGameWater" /> -->
      <el-table-column label="团队总业绩" align="center" prop="teamGameWater" />
      <el-table-column label="下注业绩" align="center" prop="betTeamGameWater" />
      <el-table-column label="托管业绩 * 30倍" align="center" prop="ddTeamGameWater" />
      <el-table-column label="团队总人数" align="center" prop="teamUsers" />
      <el-table-column label="创建时间" align="center" prop="createTime" />

      <!-- <el-table-column label="业绩金额" align="center" prop="teamGameWater" /> -->
      <el-table-column label="团队比列" align="center" prop="teamRate">
        <template slot-scope="scope">
          {{ Number( scope.row.teamRate * 100 ).toFixed(2) }}%
        </template>
      </el-table-column>
      <el-table-column label="团队奖励" align="center" prop="teamGameEarning" />

    </el-table>
    <div class="pagination">
      <el-pagination
        :current-page.sync="queryParams.pageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size.sync="queryParams.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="fetchData"
        @current-change="fetchData"
      />
    </div>
  </div>
</template>

<script>
import { teamDailyList,statisticsFor5 } from '@/api/table'
export default {
  components: {

  },
  data() {
    return {
      list: null,
      listLoading: false,
      total: 0,
      typeOptions: [
        { label: '虚拟货币', value: 'usdt' },
        { label: '人民币', value: 'rmb' }
      ],
      statusOptions: [
        { id: 'teamEarning', label: '团队奖励金额' }

      ],
      statistics:{},
      message:"",
      queryParams: {

        userId: '',
        pageNum: 1,
        pageSize: 10,
        type: '',
        date: '',
        orderDirection: 'DESC',
        orderBy: ''
      }
    }
  },
  created() {
    // this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      console.log(this.queryParams.date)
      if(this.queryParams.date){
        this.getStatisticsFor5()
      }
      
      teamDailyList(this.queryParams).then(response => {
        this.list = response.data.records
        this.listLoading = false
        this.total = response.data.total
        this.message = response.message
      })
      
    },
    async getStatisticsFor5(){
      const res = await statisticsFor5({date:this.queryParams.date})
      this.statistics = res.data
    },
    handleShowInfo(e) {
      this.$refs.showInfo.show(e)
    },
    setStateTxt(index) {
      let str = ''
      switch (Number(index)) {
        case 1:
          str = '审核中'
          break
        case 2:
          str = '已完成'
          break
        case 3:
          str = '失败'
          break
      }
      return str
    },
    setTypeTxt(index) {
      let str = ''
      switch (index) {
        case 'progressing':
          str = '进行中'
          break
        case 'end':
          str = '已结束'
          break
      }
      return str
    },
    onSubmit() {
      this.queryParams.page = 1
      this.fetchData()
    },
    reset() {
      this.queryParams = {

        date: '',

        pageNum: 1,
        pageSize: 10,
        status: ''
      }
      this.fetchData()
    },
    handleAdd() {
      this.$refs.add.show()
    },
    handleEdit(e) {
      this.$refs.add.edit(e)
    }

  }
}
</script>
